import instance from './index';
import * as util from "@/assets/util";
//获取账户列表
const request = {
  p: ['get,/user/hello'],
  r: params => {
    return instance.get(util.baseUrl+`/user/all`, {headers: {'token':util.session("token")}});
  },
  requestByUsername: params => {
    return instance.get(util.baseUrl+`/user/selectByUsername`, {params:{"username":params},headers: {'token':util.session("token")}});
  }

}
//删除账户
const remove = {
  p: ['delete,/user/**'],
  r: params => {
    return instance.delete(util.baseUrl+`/user/delete`,{params:{userId:params},headers:{'token':util.session("token")}})
  }
};

//添加账户
const add = {
  r: params => {
    return instance.delete(util.baseUrl+`/user/delete`,{params:{userId:params},headers:{'token':util.session("token")}})
  },
  addUser: params => {
    return instance.post(util.baseUrl+`user/add`,params,{headers:{"token":util.session("token")}})
  }
};

//修改账户
const edit = {
  p: ['put,/account/**'],
  r: params => {
    return instance.put(util.baseUrl+`/account/${params.id}`, params)
  }
};
//越权请求
const notAllowed = {
  p: ['get,/roles/notAllowed'],
  r: params => {
    return instance.get(util.baseUrl+`/roles/notAllowed`, {params})
  }
}

export {
  request,
  remove,
  edit,
  notAllowed
}
